﻿using System.IO;
using Peter.Properties;

namespace Peter.Logic
{
   /// <summary>
   /// Common static class used throughout Peter.
   /// </summary>
   public static class PeterCommon
   {
      /// <summary>
      /// Adds a file to the recent file list.
      /// </summary>
      /// <param name="file">File to add.</param>
      public static void AddRecentFile (FileInfo file)
      {
         if (file.Exists)
         {
            if (Settings.Default.RecentFiles.Contains (file.FullName))
               Settings.Default.RecentFiles.Remove (file.FullName);
            Settings.Default.RecentFiles.Insert (0, file.FullName);

            while (Settings.Default.RecentFiles.Count > Settings.Default.MaxRecentFiles)
               Settings.Default.RecentFiles.RemoveAt (Settings.Default.MaxRecentFiles);

            MenuItems.CheckForRecentFile (file);
         }
      }
   }
}
